<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="org.apache.commons.lang3.StringUtils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.bci.pwtz.mysql.model.CompanyRole"%>
<%@page import="com.bci.pwtz.service.impl.CompanyUserServiceImpl"%>
<%@page import="com.bci.pwtz.service.impl.CompanyRoleServiceImpl"%>
<%@page import="com.bci.pwtz.service.CompanyUserService"%>
<%@ page import="com.bci.pwtz.mysql.model.RandomCode" %>
<%@page import="java.util.List" %>
<%@ include file="/user/common.jsp"%>
<%
	String type = request.getParameter("type");
	String rcode = "";
	CompanyUserService cus = (CompanyUserServiceImpl)SpringUtil.getBean("companyUserService");
	CompanyRoleService crs = (CompanyRoleServiceImpl)SpringUtil.getBean("companyRoleService");
	if(("1").equals(type)){
	    Long cid = ((CompanyUser)session.getAttribute("user")).getLastCompanyId();
	    RandomCode r=new RandomCode();
	    List<RandomCode> list=cus.getCompanyRandomCode(cid);
	    if(list!=null&&list.size()>0){
	        rcode=list.get(0).getRandomCode();
	    }else{
	        CompanyRole cr=crs.selectDefault(cid);
		    Long crid = 0L;
		    if(cr!=null)
	        crid = cr.getCompanyRoleId();
	        rcode=cus.createRandomCode(cid, crid);
	        //rcode="";
	        if(StringUtils.isEmpty(rcode)){
	            rcode="获取邀请码失败";
	        }
	    }
	}
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>配网数据-系统主页</title>
<link href="<%=basePath %>user/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>user/css/llcss.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<%=basePath %>js/jquery/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=basePath %>user/js/hd_ll.js"></script>
<script type="text/javascript" src="<%=basePath %>user/js/common.js"></script>
<script type="text/javascript" src="<%=basePath %>user/m/js/invitefriends.js"></script>
<script type="text/javascript">
var onShow=function(){
	location.href="<%=basePath%>user/m/invitefriends.jsp?type=1";
}
</script>
</head>
<body bgcolor="white">

	<%@ include file="/user/head.jsp"%>
	<div class="pwsj_cont_box">
	<%@ include file="/user/left.jsp"%>
	<!-- 右侧内容_begin -->
	<div class="pwsj_cont_right_box">
		<!-- 邀请同事加入_begin -->
		<div class="pwsj_right_yqtsjr">
			<div class="pwsj_right_yqtsjr_position">配网数据&gt;其他功能&gt;邀请同事加入</div>
			<!-- 邀请码_begin -->
			<div class="invite_code_box">
				<!-- 邀请按钮-begin -->
				<%if(!("1").equals(type)){ %>
				<div class="invite_btn_box">
					<h2>请点击以下按钮生成邀请码：</h2>
					<a href="<%=basePath %>user/m/invitefriends.jsp?type=1"><input onclick="onShow();" type="button" class="invite_code_btn" value="生成邀请码" /></a>
				</div>
				<%} %>
				<!-- 邀请按钮-end -->
				<!-- 邀请码内容信息_begin -->
				<%if(("1").equals(type)){ %>
				<div class="invite_code">
					<h2><%if(!"获取验证码失败".equals(rcode)){ %>您的邀请码为:<%}%><%=rcode %></h2>
					<%if(!"获取验证码失败".equals(rcode)){ %>
					<p>将6位邀请码分享给您的同事或朋友，邀请他们加入所在的公司</p>
					<div class="invite_code_desc">我正在使用配电数据助手，这是一款中低、低压数据采集软件，推荐您也来使用，注册成功后，输入邀请码【<%=rcode %>】即可加入我们。
<p style="margin-top:15px;">电脑访问地址: <a >http://www.pwsj.net</a></p>
<p>APP下载地址: <a >http://www.pwsj.net/download/android/pwzs.apk</a></p>
					</div>
					<div class="clone_box">
						<div class="bdsharebuttonbox" data-tag="share_1">
						<a class="bds_mshare" data-cmd="mshare"></a>
						<a class="bds_tsina" data-cmd="tsina"></a>
						<a class="bds_baidu" data-cmd="baidu"></a>
						<a class="bds_renren" data-cmd="renren"></a>
						<a class="bds_tqq" data-cmd="tqq"></a>
						<a class="bds_more" data-cmd="more">更多</a>
					</div>
					<script>
					var txt = $(".invite_code_desc").text();
						window._bd_share_config = {
							common : {
								bdText : txt,
								bdDesc :txt,
								bdUrl:''
							},
							share : [{
								"bdSize" : 16
							}],
							slide : [{	   
								bdImg : 0,
								bdPos : "right",
								bdTop : 100
							}],
							image : [{
								viewType : 'list',
								viewPos : 'top',
								viewColor : 'black',
								viewSize : '16',
								viewList : ['qzone','tsina','huaban','tqq','renren']
							}],
							selectShare : [{
								"bdselectMiniList" : ['qzone','tqq','kaixin001','bdxc','tqf']
							}]
						}
						with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
					</script>
						<div class="clone"><input type="button" onclick="copyToClipboard();" value="复 制" /></div>
						<div class="clear"></div>
					</div>
					<%} %>
				</div>
				
				<%} %>
				<!-- 邀请码内容信息_end -->
			</div>
			<!-- 邀请码_end -->
		</div>	
		<!-- 邀请同事加入_end -->		
	</div>
	<!-- 右侧内容_end -->
	<div class="clear"></div>
	</div>
	<!--main end-->
<%@ include file="/user/foot.jsp"%>
</body>
</html>
